package com.claude.sql;

import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class TmpCheckTableManager implements TableManager{
	
	private SQLiteDatabase mSQLiteDatabase = null;

	public TmpCheckTableManager(SQLiteDatabase sqliteDatabase) {
		mSQLiteDatabase = sqliteDatabase;
	}
	
	public boolean delete(String... args) {
		mSQLiteDatabase.beginTransaction();
		try{
			mSQLiteDatabase.execSQL("delete from tmpcheck where chno = ?", args);
			mSQLiteDatabase.endTransaction();
		}catch(SQLException error){
		}finally{
			mSQLiteDatabase.endTransaction();
		}
		return true;
	}
	public boolean update(String... args) {
		return false;
	}
	public Cursor search(String... args) {
		return null;
	}
	public boolean insert(String... args) {
		mSQLiteDatabase.beginTransaction();
		try{
			Cursor cursor = mSQLiteDatabase.rawQuery("select * from tmpcheck where chno = ? and stno = ?", new String[]{args[0], args[1]});
			if(!cursor.moveToFirst()){
				mSQLiteDatabase.execSQL("insert into tmpcheck values(?, ?, ?, ?, ?, ?)", args);
				mSQLiteDatabase.setTransactionSuccessful();
			}else{
				mSQLiteDatabase.execSQL("update tmpcheck set chtype = ?, chtime = ?, stcard = ? where chno = ? and stno = ?", new String[]{args[2], args[3], args[5], args[0], args[1]});
				mSQLiteDatabase.setTransactionSuccessful();
			}
		}catch(SQLException error){
		}finally{
			mSQLiteDatabase.endTransaction();
		}
		return true;
	}
	public boolean execStatement(String sqlStatement) {
		return false;
	}
	public Cursor rawQueryStatement(String sqlStatement) {
		return null;
	}
}
